<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script type="text/javascript">
    // 要求输入一串低于10位的数字，输出对应的中文大写:

    // 例： input: 10001  --> 一万零一     ；   input:  10,000,000  -->  一千万
    var strNumber = ['零','一','二','三','四','五','六','七','八','九','十'];
    var numberOfWeight = ['', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿'];
    var num = "10001";
    chineseNumber(num);
    function chineseNumber( num ) {
     var onum = num;
     if ( onum == 0 ) {
          print(strNumber[num[0]]);
            return;
         }
        while ( num != '' ) {
             if ( num > 0 ) {
                 if ( num[0] == 0 ) { 
                      if ( num.length <= 4 )  
                            print(strNumber[num[0]]);  
         } else { 
            print(strNumber[num[0]]);    
       }    
          if ( num[0] > 0 || num.length > 4)    
                  print(numberOfWeight[num.length-1]);  
             }      
              num = num.substring(1);  
              while ( num[0] == 0 && num[1] == 0) {   
                       num = num.substring(1);  
                   }   
                  } 
                } 
                function print( s ) {   
                      document.write(s);
                     }
    </script>
  
    
</body>
</html>





